var t = require("../../../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../../../@babel/runtime/regenerator")), e = require("../../../../../@babel/runtime/helpers/asyncToGenerator"), a = require("../../../../../mycomponent/yz_pay/yz_pay"), o = getApp();

Component({
    behaviors: [ a ],
    properties: {
        gooddatas: {
            type: Object
        }
    },
    observers: {},
    lifetimes: {
        attached: function() {
            this.initDisabled();
        }
    },
    data: {
        goods: {},
        showSpecs: !1,
        groupLevel: [],
        groupModel: null,
        groupWork_disabled: !1,
        Payshow: !1,
        btnData: [],
        payKeyboardShow: !1,
        isPlaying: !1
    },
    methods: {
        initDisabled: function() {
            var t = !1;
            this.data.gooddatas.end_time && "" != this.data.gooddatas.end_time ? (0 == o.getTimeDifference(this.data.gooddatas.end_time) || o.getTimeDifference(this.data.gooddatas.start_time) > 0) && (t = !0) : t = !1, 
            this.setData({
                groupWork_disabled: t,
                showSpecs: !1,
                Payshow: !1,
                payKeyboardShow: !1,
                isPlaying: !1
            });
        },
        selectGroup: function(t) {
            var e = t.currentTarget.dataset.item;
            if (2 == e.status) this.setData({
                groupModel: e.id
            }), this.selectComponent("#yzSpecs").setData({
                popPrice: e.min_price,
                popDescription: "".concat(e.person, "人团")
            }); else {
                var a = 3 == e.status ? "已结束" : "未开始";
                wx.showToast({
                    title: a,
                    duration: 1e3,
                    icon: "none"
                });
            }
        },
        rewardPayCancelBtn: function() {
            this.setData({
                Payshow: !1
            });
        },
        showSpecsPop: function() {
            if (0 !== Number(this.data.gooddatas.surplus)) {
                var t = {};
                t.id = this.data.gooddatas.goods_id, t.thumb = this.data.gooddatas.goods_info.thumb, 
                t.stock = this.data.gooddatas.stock, t.price = this.data.gooddatas.min_price + " 起", 
                this.setData({
                    goods: t,
                    showSpecs: !0
                });
            } else wx.showToast({
                title: "开团次数已用完，请升级等级",
                duration: 1e3,
                icon: "none"
            });
        },
        getPayData: function() {
            var t = this;
            this.data.groupModel ? o._postNetWork({
                url: o.getNetAddresss("plugin.group-work.frontend.modules.alliance.controllers.pay.button"),
                success: function(e) {
                    var a = e.data;
                    1 == a.result ? t.setData({
                        btnData: a.data.buttons,
                        showSpecs: !1,
                        Payshow: !0
                    }) : wx.showToast({
                        title: a.msg,
                        duration: 1e3,
                        icon: "none"
                    });
                }
            }) : wx.showToast({
                title: "请选择开团层级！",
                duration: 1e3,
                icon: "none"
            });
        },
        payPost: function(a) {
            var s = this;
            return e(t.default.mark(function e() {
                var r, n, i;
                return t.default.wrap(function(t) {
                    for (;;) switch (t.prev = t.next) {
                      case 0:
                        if (!s.data.isPlaying) {
                            t.next = 2;
                            break;
                        }
                        return t.abrupt("return");

                      case 2:
                        if (r = a.currentTarget.dataset.info, n = {
                            pay_type: r.value,
                            spec_id: s.data.groupModel,
                            alliance_id: 0,
                            client_type: 2
                        }, !r.need_password) {
                            t.next = 9;
                            break;
                        }
                        return t.next = 7, s.getPayKeyboardPassword();

                      case 7:
                        i = t.sent, n.password = i;

                      case 9:
                        s.data.isPlaying = !0, o._getNetWork({
                            url: o.getNetAddresss("plugin.group-work.frontend.modules.alliance.controllers.apply.index"),
                            data: n,
                            success: function(t) {
                                s.data.isPlaying = !1, 1 === t.data.result ? (s.handleOtherPay(r, r.value, t.data, "groupWork"), 
                                s.setData({
                                    Payshow: !1,
                                    popupSpecs: !1,
                                    showSpecs: !1
                                })) : (wx.showModal({
                                    title: "提示",
                                    showCancel: !1,
                                    content: t.data.msg,
                                    success: function(t) {}
                                }), console.error(t));
                            },
                            fail: function(t) {
                                console.error(t);
                            }
                        });

                      case 11:
                      case "end":
                        return t.stop();
                    }
                }, e);
            }))();
        }
    }
});